package com.blue.gateway.common.request;

import com.blue.gateway.common.Request;
import com.blue.gateway.enums.ServiceChannelEnum;
import lombok.Data;

import java.math.BigDecimal;

/**
 * @author xiaoyiming
 * @date 2020/5/3 16:05
 * @depiction
 */
@Data
public class PayRequest extends Request {

    private String nonceStr;
    private String bizContent;
    //商户订单号,64个字符以内、只能包含字母、数字、下划线；需保证在商户端不重复 20150320010101001
    private String outTradeNo;
    private BigDecimal totalAmount;// total_fee
    private String subject;//body
    //交易类型 1.JSAPI -JSAPI支付2.NATIVE -Native支付3.APP -APP支付
    private String tradeType;
    //支持IPV4和IPV6两种格式的IP地址。用户的客户端IP
    private String spbillCreateIp;

    /**
     * 得到访问的渠道服务类型（支付、退款 or 查询 ...）
     *
     * @return 渠道服务枚举
     */
    @Override
    public ServiceChannelEnum getServiceChannelEnum() {
        return ServiceChannelEnum.PAY;
    }

    public String getSpbillCreateIp() {
        if (this.spbillCreateIp == null || this.spbillCreateIp.length() == 0) {
            return "8.8.8.8";
        }
        return this.spbillCreateIp;
    }
}
